﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iTunesLib;

namespace iTunesFastForward.LastFM
{
    public class TrackSubmission : IEquatable<TrackSubmission>
    {

        public string Artist { get; set; }
        public string TrackName { get; set; }
        public string Album { get; set; }
        public int Seconds { get; set; }
        public int TrackNumber { get; set; }
        public DateTime StartedPlayingDate { get; set; }

        public static TrackSubmission FromIITTrack(IITTrack track)
        {
            if (track == null)
                return null;
            return new TrackSubmission
            {
                Artist = track.Artist,
                TrackName = track.Name,
                Album = track.Album,
                Seconds = track.Duration,
                TrackNumber = track.TrackNumber
            };
        }


        #region IEquatable<TrackSubmission> Members

        public bool Equals(TrackSubmission other)
        {
            if (other == null)
                return false;
            if (
                Artist == other.Artist &&
                TrackName == other.TrackName &&
                Album == other.Album &&
                Seconds == other.Seconds &&
                TrackNumber == other.TrackNumber)
                return true;
            else
                return false;
        }

        #endregion
    }
}
